package com.zhongyewx.teachercert.db;

import android.arch.persistence.db.SupportSQLiteOpenHelper;
import android.arch.persistence.room.Database;
import android.arch.persistence.room.DatabaseConfiguration;
import android.arch.persistence.room.InvalidationTracker;
import android.arch.persistence.room.Room;
import android.arch.persistence.room.RoomDatabase;
import android.content.Context;
import android.support.annotation.NonNull;

import com.zhongyewx.teachercert.db.dao.ZYUserDao;
import com.zhongyewx.teachercert.db.entity.UserEntity;

@Database(entities = {UserEntity.class}, version=1)
public abstract class ZYTCDataBase extends RoomDatabase {
    private static volatile ZYTCDataBase INSTANCE;

    public static ZYTCDataBase instance(Context context){
        if (INSTANCE == null) {
            synchronized (ZYTCDataBase.class) {
                if (INSTANCE == null) {
                    INSTANCE = Room.databaseBuilder(context.getApplicationContext(),
                            ZYTCDataBase.class, "zyteacher_cert").build();
                }
            }
        }
        return INSTANCE;
    }

    public abstract ZYUserDao getUserDao();

    @NonNull
    @Override
    protected SupportSQLiteOpenHelper createOpenHelper(DatabaseConfiguration config) {
        return null;
    }

    @NonNull
    @Override
    protected InvalidationTracker createInvalidationTracker() {
        return null;
    }

    @Override
    public void clearAllTables() {

    }
}
